const BingWallpaper = require('./bing_wallpaper');
const QiHuWallpaper = require('./qihu_wallpaper');

class DataSourceFactory {
    constructor() {
        this.wp360 = 'wp360';
        this.wpBing = 'wpBing';
        this.platforms = {};
        this.currentPlatform = this.wpBing;
        this.platforms[this.wpBing] = {
            'name' : '必应壁纸',
            'code' : this.wpBing,
            'link' : 'https://bing.ioliu.cn/'
        };
        this.platforms[this.wp360] = {
            'name' : '360壁纸',
            'code' : this.wp360,
            'link' : 'http://bizhi.360.cn/'
        };
    }
    getPlatforms() {
        return this.platforms;
    }

    setCurrentPlatform(platform = this.wpBing) {
        this.currentPlatform = platform;
        return this;
    }

    getCurrentPlatform() {
        return this.currentPlatform;
    }

    getDataSource() {
        let dataSourceObj = {};
        switch (this.currentPlatform) {
            case this.wp360:
                dataSourceObj = new QiHuWallpaper();
                break;
            default:
                dataSourceObj = new BingWallpaper();
                break;
        }
        return dataSourceObj;
    }
}
module.exports = DataSourceFactory;
